﻿/******************************************************************************
 * GBookTypes.cs
 * 
 * This module implements the DataContract types needed to query Google Books
 * 
 * Date:   12/2008
 * 
 * Copyright (c) 2009, 2010, Mark Betz 
 * 
 * All rights reserved. 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright 
 *     notice, this list of conditions and the following disclaimer. 
 *   * Redistributions in binary form must reproduce the above copyright 
 *     notice, this list of conditions and the following disclaimer in the 
 *     documentation and/or other materials provided with the distribution. 
 *   * Neither the name of the Author nor the names of contributors may be 
 *     used to endorse or promote products derived from this software
 *     without specific prior written permission. 
 *     
 * THIS SOFTWARE IS PROVIDED BY MARK BETZ ''AS IS'' AND ANY  EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL MARK BETZ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 * 
 */
using System;
using System.Runtime.Serialization;

namespace GSearch
{
    /// <summary>
    /// Implements the book-specific portion of the Google result json object
    /// </summary>
    [DataContract]
    public class GBookResults : GResults
    {
        /// <summary>
        /// A System.String containing the title of the book. May contain
        /// HTML formatting.
        /// </summary>
        [DataMember (Name="title")]
        public string Title { get; set; }

        /// <summary>
        /// A System.String containing the title of the book, without any
        /// HTML formatting.
        /// </summary>
        [DataMember (Name="titleNoFormatting")]
        public string TitleNoFormatting { get; set; }
        
        /// <summary>
        /// A System.String containing the full URL address of the book on
        /// Google Books, without escape characters.
        /// </summary>
        [DataMember (Name="unescapedUrl")]
        public string UnescapedUrl { get; set; }

        /// <summary>
        /// A System.String containing the full URL address of the book on
        /// Google Books, with escape characters.
        /// </summary>
        [DataMember(Name = "Url")]
        public string Url { get; set; }

        /// <summary>
        /// A System.String containing the names of the book's author(s)
        /// </summary>
        [DataMember (Name="authors")]
        public string Authors { get; set; }
        
        /// <summary>
        /// A System.String containing the book's 'id'. In the US this is the
        /// ISBN number assigned to the book.
        /// </summary>
        [DataMember (Name="bookId")]
        public string BookId { get; set; }
        
        /// <summary>
        /// A System.String containing the year in which the book edition was
        /// published
        /// </summary>
        [DataMember (Name="publishedYear")]
        public string PublishedYear { get; set; }        
        
        /// <summary>
        /// A System.Int32 containing the number of pages in the book.
        /// </summary>
        [DataMember (Name="pageCount")]
        public int PageCount { get; set; }
        
        /// <summary>
        /// A System.String containing the URL address of a thumbnail image
        /// associated with the book.
        /// </summary>
        [DataMember (Name="tbUrl")]
        public string TbUrl { get; set; }
    }

    /// <summary>
    /// Implements the book-specific portion of the Google responseData json object
    /// </summary>
    [DataContract]
    public class GBookResponseData : GResponseData
    {
        /// <summary>
        /// Returns an array of <see cref="GSearch.GBookResults"/> objects containing
        /// the results from a search.
        /// </summary>
        [DataMember(Name = "results")]
        public GBookResults[] Results { get; set; }
    }

    /// <summary>
    /// Implements the book-specific portion of the Google response json object
    /// </summary>
    [DataContract]
    public class GBookResponse : GResponse
    {
        /// <summary>
        /// An instance of <see cref="GSearch.GBookResponseData"/> containing
        /// the results of a search.
        /// </summary>
        [DataMember(Name = "responseData")]
        public GBookResponseData Response { get; set; }
    }
}
